
Public Class ODBCHelper
    ' has two overloads for GetDataSetFromAdapter that work for OBDC connections (instead of SQL connections)
    ' and also contains an original sample source code from msdn


    ' GetDataSetFromAdapter
    ' returns a data set from and ODBC data source given a connection string and a query string
    ' this is adapted from the sample code above
    Public Overloads Shared Function GetDataSetFromAdapter( _
            ByVal connectionString As String, _
            ByVal queryString As String) As System.Data.DataSet

        Dim connection As System.Data.Odbc.OdbcConnection = New System.Data.Odbc.OdbcConnection(connectionString)
        Dim query As System.Data.Odbc.OdbcCommand = New System.Data.Odbc.OdbcCommand(queryString, connection)

        Return GetDataSetFromAdapter(connection, query)

    End Function

    ' GetDataSetFromAdapter
    ' returns a data set from an ODBC data source given a connection string and a query string
    ' this is adapted from the sample code above
    Public Overloads Shared Function GetDataSetFromAdapter( _
            ByVal connection As System.Data.Odbc.OdbcConnection, _
            ByVal query As System.Data.Odbc.OdbcCommand) As System.Data.DataSet

        Dim dataSet As System.Data.DataSet = New System.Data.DataSet()
        Dim adapter As New System.Data.Odbc.OdbcDataAdapter(query)

        ' Open the connection and fill the DataSet.
        Try
            connection.Open()
            adapter.Fill(dataSet)
        Catch ex As Exception
            Console.WriteLine(ex.Message)
        Finally
            connection.Close()
        End Try

        Return dataSet
    End Function




    ' GetDataSetFromAdapter
    ' this is straight from: http://msdn.microsoft.com/en-us/library/system.data.odbc.odbcdataadapter.aspx
    Private Shared Function GetDataSetFromAdapter_SampleCode( _
            ByVal dataSet As System.Data.DataSet, ByVal connectionString As String, _
            ByVal queryString As String) As System.Data.DataSet

        Using connection As New System.Data.Odbc.OdbcConnection(connectionString)
            Dim adapter As New System.Data.Odbc.OdbcDataAdapter(queryString, connection)

            ' Open the connection and fill the DataSet.
            Try
                connection.Open()
                adapter.Fill(dataSet)
            Catch ex As Exception
                Console.WriteLine(ex.Message)
            End Try
            ' The connection is automatically closed when the
            ' code exits the Using block.
        End Using

        Return dataSet
    End Function

End Class
